﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:graph="clr-namespace:zeal.ui.graph">
    <Style TargetType="{x:Type graph:GraphNode}">
        <Style.Resources>
            <SolidColorBrush x:Key="NodeBackground" Color="#FF393939" />
            <SolidColorBrush x:Key="NodeBorderBackground" Color="#FF202020" />
            <SolidColorBrush x:Key="HeaderHoverBackground" Color="#20FFFFFF" />
            <LinearGradientBrush x:Key="HeaderSelectedBackground" StartPoint="0.5,0" EndPoint="0.5,1">
                <GradientStop Color="#FFFFFFFF" Offset="0" />
                <GradientStop Color="#FF737373" Offset="1" />
            </LinearGradientBrush>
            <Style x:Key="PortViewStyle" TargetType="{x:Type ItemsControl}">
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Vertical" MinWidth="60" />
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Style.Resources>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type graph:GraphNode}">
                    <Border Background="{StaticResource NodeBorderBackground}" Margin="0" Padding="2" CornerRadius="8" SnapsToDevicePixels="False" Cursor="Arrow">
                        <StackPanel>
                            <Grid x:Name="PART_header" Cursor="SizeAll">
                                <Border x:Name="PART_headerBorder" CornerRadius="8,8,0,0" Height="26" Background="{StaticResource NodeBackground}">
                                    <StackPanel Orientation="Horizontal" VerticalAlignment="Stretch">
                                        <TextBlock x:Name="PART_headerText" Text="{Binding name}" Margin="4,0,0,0" VerticalAlignment="Center" ClipToBounds="True"
                                                   TextAlignment="Left" FontWeight="Bold" Foreground="White" TextOptions.TextFormattingMode="Display" />
                                    </StackPanel>
                                </Border>
                                <Border x:Name="PART_headerHover" CornerRadius="8,8,0,0" Visibility="Hidden" IsHitTestVisible="False"
                                        Background="{StaticResource HeaderHoverBackground}"/>
                                
                            </Grid>
                            <Separator Height="2" Background="Transparent" HorizontalAlignment="Stretch" Margin="0"/>
                            <Border Background="{StaticResource NodeBackground}" CornerRadius="0,0,8,8" Margin="0">
                                <StackPanel Orientation="Horizontal">
                                    <ItemsControl ItemsSource="{Binding inPorts}" Style="{StaticResource PortViewStyle}"/>
                                    <ItemsControl ItemsSource="{Binding outPorts}" Style="{StaticResource PortViewStyle}"/>
                                </StackPanel>
                            </Border>
                        </StackPanel>
                        <Border.Effect>
                            <DropShadowEffect BlurRadius="15" Opacity="1" Direction="300" RenderingBias="Performance"/>
                        </Border.Effect>
                    </Border>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding IsSelected}" Value="True">
                            <Setter TargetName="PART_headerText" Property="TextBlock.Foreground" Value="Black" />
                            <Setter TargetName="PART_headerBorder" Property="Border.Background" Value="{StaticResource HeaderSelectedBackground}" />
                        </DataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding ElementName=PART_header, Path=IsMouseOver}" Value="True" />
                                <Condition Binding="{Binding IsSelected}" Value="False" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="PART_headerHover" Property="UIElement.Visibility" Value="Visible" />
                        </MultiDataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>